<template>
	<view>
		<button class="fanhui" @click="fanhui" type="primary">返回</button>
		 <view class="all">
			  <input v-model="yuanmi" placeholder="原密码"/>
			  <input v-model="xinmi1" placeholder="新密码"/>
			   <input v-model="xinmi2" placeholder="再次输入新密码"/>
		 </view>
		 <button class="xiugai" type="primary" @click="xiugaimima">修改密码</button>
			
		 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yuanmi:'',
				xinmi1:'',
				xinmi2:'',
				zhang:'',
				jieguo:''
			}
		},
		onLoad(){
			this.zhang=getApp().globalData.zhang
		},
		methods: {
			async xiugaimima(){
				if(this.yuanmi==''||this.xinmi1==''||this.xinmi2=='')
				 {
					 uni.showToast({
				 	title: "请输入完整!",
					duration:2000,
					icon:'error'
				      })
				 }
				else if(this.xinmi1!=this.xinmi2)
				 {
					 uni.showToast({
					 title: "新密码不一致!",
					 duration:2000,
					 icon:'error'
				         })
				 }
				else {
					
					 uni.request({
				  	url:"http://124.221.104.5:8080/jbgn/gaimima",
					data:{zhang:this.zhang,yuanmi:this.yuanmi,xinmi:this.xinmi1},
					success: (res) => {
						this.jieguo =res.data
					    }
				           })
						   await new Promise((res)=>setTimeout(res,500))
							 if(this.jieguo=="修改成功!")
				        { 
							uni.showToast({
							title: this.jieguo,
							duration:1000,
							icon:'success' })
						await new Promise((res)=>setTimeout(res,1000))	
						uni.navigateBack();
				         }
						 else{
							  uni.showToast({
						    title: this.jieguo,
						     duration:1000,
						     icon:'error' })
							 console.log("失败")
						 }
				}
				 
			
		},
		  fanhui(){
			 uni.navigateBack()
		    }
		
	}
	}
</script>

<style>
	.fanhui{
		width: 40rpx;
		height: 40rpx;
		margin-left: 0rpx;
	}
.all{
	margin-top: 250rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
  }
  .all input{
	 border: 3rpx solid antiquewhite;
	 border-radius: 15rpx;
	 margin-top: 15rpx;
	 height: 70rpx;
	 width: 400rpx;
  }
  .xiugai{
	  width:200rpx ;
	  margin-top: 100rpx;
  }
</style>
